import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token: null,
    user: null,
  },
  getters: {
    token: (state) => state.token,
    user: (state) => state.user,
  },
  mutations: {
    SET_TOKEN: (state, token) => {
      state.token = token
    },
    SET_USER: (state, user) => {
      state.user = user
    },
  },
  actions: {},
  modules: {},
  plugins: [
    createPersistedState({
      storage: sessionStorage,
    }),
  ],
})
